package com.lagou.springboot.work.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lagou.springboot.work.dao.ArticleDao;
import com.lagou.springboot.work.entity.ArticleEntity;
import com.lagou.springboot.work.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ArticleServiceImpl implements ArticleService {

    @Autowired
    private ArticleDao articleDao;

    @Override
    public ArticleEntity findById(int id) {
        return articleDao.findById(id);
    }

    @Override
    public PageInfo<ArticleEntity> findPages(int pageNum) {
        PageHelper.startPage(pageNum, 2);
        List<ArticleEntity> articleEntityList =   articleDao.findPages(null);
        return new PageInfo(articleEntityList);
    }
}
